/************************************************************************************
NOTE: after running this test, you will have a volume from cloud-tools-enable-ebs, 
and a snapshot of the volume from cloud-tools-create-snapshot it would be a good idea 
to  get rid of those things with a tool like ElasticFox
*************************************************************************************/
class BasicsTests extends CloudToolsBaseTests{
	
	void testBasics(){
		//test deploy
		def result = executeGrailsCommand("cloud-tools-deploy", null)
		assertExitValue(0, result);
	    assertStdOut("Finished deploying cluster", result);
	
		//test for bad enable-ebs
		result = executeGrailsCommand("cloud-tools-enable-ebs", null)
		assertExitValue(0, result);
	    assertStdErr("You did not specify either 'cloudtools.ebs.volume.size' or 'cloudtools.ebs.device'", result);
	
		//test for enable-ebs
		result = executeGrailsCommand("-Dcloudtools.ebs.volume.size=1 -Dcloudtools.ebs.device=/dev/sdj cloud-tools-enable-ebs", null)
		assertExitValue(0, result);
	    assertStdOut("Creating a new volume of size: 1", result);
		assertStdOut("Configuring database", result);
		assertStdOut("Saving Cluster", result);
		assertStdOut("Done", result);
		
		//test for create snapshot
		result = executeGrailsCommand("cloud-tools-create-snapshot", null)
		assertExitValue(0, result);
	    assertStdOut("Snapshot created: ", result);
	
		//test for bad db-save
		result = executeGrailsCommand("cloud-tools-db-save", null)
		assertExitValue(0, result);
	    assertStdErr("You must specify cloudtools.s3.path", result);
	
		//test for db-save
		result = executeGrailsCommand("-Dcloudtools.s3.path=cloudtoolstest/backup.sql cloud-tools-db-save", null)
		assertExitValue(0, result);
	    assertStdOut("Save Completed to", result);
	
		//test for bad db-restore
		result = executeGrailsCommand("cloud-tools-db-restore", null)
		assertExitValue(0, result);
	    assertStdErr("You must specify cloudtools.s3.path", result);
	
		//test for db-restore
		result = executeGrailsCommand("-Dcloudtools.s3.path=cloudtoolstest/backup.sql cloud-tools-db-restore", null)
		assertExitValue(0, result);
	    assertStdOut("Finished with db-restore on", result);
	
		/*************** THIS MUST BE THE LAST ASSERT SINCE IT STOPS THE CLUSTER***********************/
		//test for stop
		result = executeGrailsCommand("cloud-tools-stop", null)
		assertExitValue(0, result);
	    assertStdOut("Stopped cluster", result);
	}
}